import json

with open('1.json','r') as fr:
    all11 = json.loads(fr.read())['all']

with open('2.json', 'r') as fr:
    all22 = json.loads(fr.read())['all']

all1 = []
all2 = []
for a in all11:
    if a['addr'] != '404':
        all1.append(a)
for a in all22:
    if a['addr'] != '404':
        all2.append(a)
out = []

print(len(all1), len(all2))
for item1 in all1:
    k = 0
    while k < len(all2):
        if item1['name_fmt'] == all2[k]['name_fmt']:
            del all2[k]
        else:
            k += 1
all = all1 + all2
print(len(all))

with open('hubei222.json','w') as fw:
    fw.write(json.dumps({'all':all}, separators=(',',':'), ensure_ascii=False))

# remove duplicates
# print(len(all), all, len(all1), len(all2))
#
# i = 0
# while i < len(all):
#     k = 0
#     while k < len(all):
#         if i != k and all[i]['name_fmt'] == all[k]['name_fmt']:
#             del all[k]
#         else:
#             k += 1
#     i += 1
# print(len(all))
